#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;
const int N = 100010;

struct Range
{
    int l, r;
    bool operator<(const Range &m) const
    {
        return r < m.r;
    }
} range[N];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int l, r;
        scanf("%d %d", &l, &r);
        range[i] = {l, r};
    }
    sort(range, range + n);
    int count = 0, ed = INT_MIN;
    for (int i = 0; i < n; ++i)
    {
        if (range[i].l > ed)
        {
            ++count;
            ed = range[i].r;
        }
    }
    printf("%d", count);
    return 0;
}